package shop;

public class Shop {

	static final int MAXN = 10;
	String[] types;
	int[] price;
	int pointer;

	public Shop() {
		types = new String[MAXN];
		price = new int[MAXN];
		pointer = 0;
	}

	public void addNew(String name, int amount) {
		if (pointer == MAXN)
			return;
		types[pointer] = name;
		price[pointer] = amount;
		++pointer;
	}

	public void modify(String name, int amount) {
		for (int i = 0; i < pointer; ++i)
			if (types[i].equals(name)) {
				price[i] = amount;
				return;
			}
	}

	public int getPrice(String name) {
		for (int i = 0; i < pointer; ++i)
			if (types[i].equals(name))
				return price[i];
		return 0;
	}
	public String getName(int index) {
		return types[index];
	}

	public String[] getAllItem() {
		String[] newS = new String[pointer];
		for (int i = 0; i < pointer; ++i)
			newS[i] = types[i];
		return newS;
	}

}
